/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

/**
 *
 * @author vimi Administrator
 * Dinh Ngoc
 *
 */
import java.lang.String;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;



public class Curriculum {
    public String CurriculumID;
    public int CourseNum;

    public List<String> CourseIDs;
    public List<String> CIndexList;

    public Curriculum(String _CurriculumID, int _CourseNum)
    {
        this.CurriculumID = _CurriculumID;
        this.CourseNum = _CourseNum;

        // Courses
        CourseIDs = new ArrayList();
        CIndexList = new ArrayList();
    }

    // getter & setter
    public boolean add2CourseIDs(String _newCourseID)
    {
        return this.CourseIDs.add(_newCourseID);
    }

    public boolean add2CIndexList(String _newCIndex)
    {
        return this.CIndexList.add(_newCIndex);
    }

    // update index list when the order in a list of courses has changed
    public void updateCIndexList(List<Course> _Courses)
    {
        // test
        /*
        for (int i=0;i<=_Courses.size()-1;i++)
        {
            System.out.println(i+":"+_Courses.get(i).getCourseID());
        }
         */

        for (int i=0;i<=CourseIDs.size()-1;i++)
        {
            String IthText= CourseIDs.get(i);

            int index = -1;
            
            for (int j=0;j<=_Courses.size()-1;j++)
            {
               if (IthText.equals(_Courses.get(j).getCourseID())) index=j;
            }

            //System.out.print("| IthText,index:"+IthText+","+index);



            CIndexList.set(i, Integer.toString(index));
        }
    }

    // public util
    public static void updateCIndex4Curricula(List<Curriculum> _Curricula, List<Course> _Courses)
    {
        for (int i=0;i<=_Curricula.size()-1;i++)
        {
            Curriculum IthCurriculum=_Curricula.get(i);

            IthCurriculum.updateCIndexList(_Courses);
        }
    }


}